package br.com.caelum.vraptor.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.dao.GenericDAO;
import br.com.caelum.vraptor.entidades.Dieta;

@Controller
public class DietaController {
	
	@Inject
	private Result result;
	
	@Inject
	private GenericDAO<Dieta> dao;
	
	public void addD(){
		
	}
	

	public List<Dieta> listD(){
		return dao.find();
	}
	
	public void save(Dieta dieta){
		
		dao.save(dieta);
		
		result.redirectTo(this).listD();
	}
	
	public Dieta edit(Integer id){
		return dao.find(id);
	}
	
	public void delete(int id){
		Dieta dieta = new Dieta();
		dieta.setId(id);
		dao.delete(dieta);
		result.redirectTo(this).listD();
	}
	
}